<template>
  <div class="my">
    <div class="top">
      <div class="user">
        <div class="left">
          <div class="left-top">{{ userInfo.nickname }}</div>
          <div class="left-bottom">{{ userInfo.intro }}</div>
        </div>
        <img
          v-if="userInfo.avatar"
          class="right"
          :src="baseUrl + userInfo.avatar"
          alt=""
          @click="$router.push('/home/myInfo')"
        />
        <img
          v-else
          @click="$router.push('/home/myInfo')"
          class="right"
          src="@/assets/logo.png"
          alt=""
        />
      </div>
      <ul class="data">
        <li class="item">
          <div class="num">298</div>
          <div class="txt">累计答题</div>
        </li>
        <li class="item">
          <div class="num">98</div>
          <div class="txt">收藏题目</div>
        </li>
        <li class="item">
          <div class="num">198</div>
          <div class="txt">我的错题</div>
        </li>
        <li class="item">
          <div class="num">76 <small>%</small></div>
          <div class="txt">正确率</div>
        </li>
      </ul>
      <div class="pis">
        <mycell class="cell" icon="&#xe64d;" title="我的岗位" value="产品经理">
        </mycell>
      </div>
    </div>
    <div class="content">
      <div class="middle">
        <h3>面经数据</h3>
        <ul class="data-total">
          <li class="total-item">
            <div class="t1">昨日阅读<span class="color">+300</span></div>
            <div class="num">17</div>
            <div class="txt">阅读总数</div>
          </li>
          <li class="total-item">
            <div class="t1">昨日获赞<span class="color">+300</span></div>
            <div class="num">297</div>
            <div class="txt">获赞总数</div>
          </li>
          <li class="total-item">
            <div class="t1">昨日新增<span class="color">+300</span></div>
            <div class="num">187</div>
            <div class="txt">评论总数</div>
          </li>
        </ul>
      </div>
      <div class="bottom">
        <mycell
          class="round"
          icon="&#xe655;"
          title="我的面经分享"
          value="21"
        ></mycell>
        <mycell icon="&#xe655;" title="我的面经分享" value="21"></mycell>
        <mycell icon="&#xe655;" title="我的面经分享" value="21"></mycell>
        <mycell icon="&#xe655;" title="我的面经分享" value="21"></mycell>
        <mycell icon="&#xe655;" title="我的面经分享" value="21"></mycell>
        <mycell icon="&#xe655;" title="我的面经分享" value="21"></mycell>
      </div>
    </div>
  </div>
</template>

<script>
import mycell from './mycell'
import { mapState } from 'vuex' // 使用mapState和计算属性来让获取到的数据填写更简单
export default {
  computed: {
    ...mapState(['userInfo'])
    /* user() {
        return this.$store.state.userInfo
    } */
  },
  components: {
    mycell
  },
  data () {
    return {
      baseUrl: process.env.VUE_APP_URL
    }
  },
  methods: {}
}
</script>

<style lang="less" scoped>
.my {
  .top {
    background-color: #c7002f;
    padding: 31px @p15 0;
    position: relative;
    .user {
      display: flex;
      align-items: center;
      .left {
        flex: 1;
        .left-top {
          font-size: 21px;
          font-family: PingFangSC, PingFangSC-Semibold;
          font-weight: 600;
          text-align: left;
          color: #ffffff;
          line-height: 30px;
          letter-spacing: 0px;
        }
        .left-bottom {
          opacity: 0.7;
          font-size: 12px;
          font-family: PingFangSC, PingFangSC-Regular;
          font-weight: 400;
          text-align: left;
          color: #ffffff;
          line-height: 17px;
          letter-spacing: 0px;
        }
      }
      .right {
        width: 50px;
        height: 50px;
        border: 3px solid rgba(255, 255, 255, 0.38);
        border-radius: 50%;
      }
    }
    .data {
      display: flex;
      align-items: center;
      justify-content: space-around;
      margin-top: 30px;
      padding-bottom: 55px;
      .num {
        font-size: 21px;
        font-family: DINAlternate, DINAlternate-Bold;
        font-weight: 700;
        text-align: center;
        color: #ffffff;
        line-height: 24px;
        letter-spacing: 0px;
      }
      .txt {
        opacity: 0.7;
        font-size: 12px;
        font-family: PingFangSC, PingFangSC-Regular;
        font-weight: 400;
        text-align: center;
        color: #ffffff;
        line-height: 16px;
        letter-spacing: 0px;
      }
    }
    .pis {
      position: absolute;
      left: 0;
      width: 100%;
      bottom: -16px;
      padding: 0 @p15;
      .cell {
        border-top-left-radius: 10px;
        border-top-right-radius: 10px;
      }
    }
  }
  .content {
    padding: 26px @p15;
    background-color: #f7f4f5;
    .middle {
      padding: 15px;
      background: #ffffff;
      border-radius: 8px;
      margin-bottom: 15px;
      h3 {
        font-size: 14px;
        font-family: PingFangSC, PingFangSC-Semibold;
        font-weight: 600;
        text-align: left;
        color: #181a39;
        line-height: 20px;
        letter-spacing: 0px;
        margin-bottom: 20px;
      }
      .data-total {
        display: flex;
        // align-items: center;
        text-align: center;
        justify-content: space-around;
        .t1 {
          font-size: 12px;
          font-family: PingFangSC, PingFangSC-Regular;
          font-weight: 400;
          text-align: center;
          color: #b4b4bd;
          line-height: 14px;
          letter-spacing: 0px;
          .color {
            color: #65d3e3;
          }
        }
        .num {
          font-size: 21px;
          font-family: DINAlternate, DINAlternate-Bold;
          font-weight: 700;
          text-align: center;
          color: #181a39;
          line-height: 24px;
          letter-spacing: 0px;
        }
        .txt {
          font-size: 12px;
          font-family: PingFangSC, PingFangSC-Regular;
          font-weight: 400;
          text-align: center;
          color: #545671;
          line-height: 16px;
          letter-spacing: 0px;
        }
      }
    }
    .bottom {
      margin-top: 20px;
      .round {
        border-top-left-radius: 10px;
        border-top-right-radius: 10px;
      }
    }
  }
}
</style>
